/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rultax.blackice.controller;

import java.util.ArrayList;
import java.util.List;
import org.jbox2d.dynamics.Body;

/**
 * Controller that operates over multiple Bodies.
 * 
 * @author rultax
 */
public abstract class MultiController extends Controller{
    private List<Body> bodies;
    
    /**
     * Creates a new instance of MultiController
     */
    public MultiController(){
	bodies = new ArrayList<Body>();
    }
    
    /**
     * Sets awake to true for all bodies.
     */
    public void wakeAll(){
	for(Body body : bodies)
	    body.setAwake(true);
    }
    
    /**
     * Adds a list of bodies to bodies.
     * 
     * @param bodies
     */
    public final void addBodies(List<Body> bodies){
	for (Body body : bodies) {
	    addBody(body);
	}
    }
    
    /**
     * Adds a body to bodies.
     * 
     * @param b
     */
    public final void addBody(Body b){
	bodies.add(b);
    }
    
    /**
     * Removes a body from bodies.
     * 
     * @param b
     */
    public final void removeBody(Body b){
	bodies.remove(b);
    }
    
    /**
     * Gets the list of bodies.
     * 
     * @return
     */
    public final List<Body> getBodies(){
	return bodies;
    }
}
